package com.easy.sso.controller;

import com.easy.common.util.Result;
import com.easy.sso.dto.User;
import com.easy.sso.service.CheckLoginService;
import com.easy.sso.service.LoginService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: CoolPro
 * @Description:
 * @Time: 2024-04-19 18:55
 **/
@RestController
@CrossOrigin
public class LoginController {
    @Resource
    private LoginService loginService;
    @Resource
    private CheckLoginService checkLoginService;

    //设置响应的编码是utf-8

    @PostMapping(value ="/login", produces = "application/json;charset=utf-8")
    public Result login(@RequestBody User user) {
        return loginService.login(user);
    }

    @PutMapping("/register")
    public Result register(@RequestBody User user) {
        return loginService.register(user);
    }

    @GetMapping("/checkLogin")
    public Result checkLogin(@RequestParam String token) {
        return checkLoginService.checkLogin(token);
    }
}
